<%@page import="forms.*, java.util.*" %>

<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>
<%@ page import="javax.sql.*"%>

<%@ page isELIgnored ="false" %> 

<html:html>

<font size="6">Provide degrees - Choose discipline</font>
<p>

<body>

	<!-- in case validation of the entry data fails in the data bean -->
	<html:errors />


	<ul style="list-style:none; margin: 0px;"> 
        <li><b>First Name: </b>${applicantDataBean.firstname} </li> 
        <li><b>Middle Name: </b>${applicantDataBean.middlename} </li>
        <li><b>Last Name: </b>${applicantDataBean.lastname} </li>
    </ul> <br>
    
    <b>Country of citizenship: </b>${applicantDataBean.country1} <br>
    <b>Country of residence: </b>${applicantDataBean.country2}
    
    <p>
    <b>Address: </b>${applicantDataBean.address} <br>
    <b>City: </b>${applicantDataBean.city} <br>
    
    <%
    // if "state" is NOT null, means they came from addressPage directly, means they ARE a US citizen
    if (request.getSession().getAttribute("state") != null)  {
    	out.println ("<b>State: </b>" + request.getSession().getAttribute("state"));
    }
    // else means they came from residencyPage, means they ARE NOT a US citizen
    else  {
    	out.println ("<b>Country Code: </b>" + request.getSession().getAttribute("countrycode"));
    }
    %>
    
    <br>
    <b>Zip Code: </b>${applicantDataBean.zipcode} <br>
    <b>Area Code: </b>${applicantDataBean.areacode} <br>
    <b>Telephone Number: </b>${applicantDataBean.telephonenumber}
    
    <p>
    
       	Current counter: <%= request.getSession().getAttribute("SessionCounter") %>
       	<br>
	
	
	<%
	// if not the first time visiting, print out FIRST DEGREE's information
	if (!request.getSession().getAttribute("SessionCounter").equals(0))  {
		List<Degree> theDegreeArray = (LinkedList<Degree>) request.getSession().getAttribute("TheSessionDegreeArray");
		
		for (int i = 0; i < (Integer)(request.getSession().getAttribute("SessionCounter")); i++)  {
			
			Degree currentDegree = theDegreeArray.get(i);
			String currentLocationName = currentDegree.getLocation();
			String currentUniversityName = currentDegree.getUniversity();
			String currentMajorName = currentDegree.getMajor();
			String currentDegreeTitle = currentDegree.getDegreeTitle();
			String currentMonth = currentDegree.getMonth();
			String currentYear = currentDegree.getYear();
			String currentGPA = currentDegree.getGPA();
			String currentTranscriptFile = currentDegree.getMyFile().getFileName();
			out.println ("<br>" + "<b>Location of university: </b>" + currentLocationName + "<br>");
			out.println ("<b>Name of university: </b>" + currentUniversityName + "<br>");
			out.println ("<b>Major: </b>" + currentMajorName + "<br>");
			out.println ("<b>Degree title: </b>" + currentDegreeTitle + "<br>");
			out.println ("<b>Month: </b>" + currentMonth + "<br>");
			out.println ("<b>Year: </b>" + currentYear + "<br>");
			out.println ("<b>GPA: </b>" + currentGPA + "<br>");
			out.println ("<b>Transcript file: </b>" + currentTranscriptFile + "<br>");
		}
	}
	else
	{
	}
    %>
	
	
	
	<%
	List<Degree> theDegreeArray;
	if (session.getAttribute("TheSessionDegreeArray") != null)
	{
		// retrieve list from session attribute if it exists
		theDegreeArray = (LinkedList<Degree>) session.getAttribute("TheSessionDegreeArray");
	}
	else
	{
		// create the list otherwise
		theDegreeArray = new LinkedList<Degree>();
	}
		
	Integer currentCount = (Integer)(session.getAttribute("SessionCounter"));
	session.setAttribute ("TheSessionDegreeArray", theDegreeArray);
	%>
    
    
    <%	
    	String currentLocationName = theDegreeArray.get(currentCount).getLocation().replace('_', ' ');
    	String currentUniversityName = theDegreeArray.get(currentCount).getUniversity().replace('_', ' ');
    
		
	%>
	
	<br>
	<b>Location of university: </b>  <%= currentLocationName%>
    <br>
    <b>University name: </b> <%= currentUniversityName%>


	<p>
	What is your major?
	
	<html:form method="POST" action="/showMoreDegreesPage" enctype="multipart/form-data">
	
	<%
	RowSet crsMajors = (RowSet) request.getAttribute("crsMajors");
	
	
	for (int i = 0; i < 4; i++)
	{ 
		crsMajors.next();
		%>
		<html:radio property="major" value="<%=crsMajors.getString(\"discipline_name\")%>"/> 
		<%= crsMajors.getString("discipline_name")%><br>

		<%
		
	}
	%>
	<html:radio property="major" value="other"/> Other:
		<html:text property="otherMajor"/><p>
		
	When were you awarded your degree? Or when is it expected to be awarded?<br>
	Month (1-12): <html:text property="month" size="2"/> Year: <html:text property="year" size="4"/><p>
	
	What is your GPA or expected GPA when you graduate? <html:text property="GPA" size="4"/><p>
	
	What is your title of degree?<html:select property="degreeTitle">
	<html:option value=""/>
	<html:option value="BS"/>
	<html:option value="MS"/>
	<html:option value="PhD"/>
	</html:select><p>
	
	Please upload your transcript. (pdf only)<br>
	<html:text property="firstName"/>
	<html:file property="myFile"/>
	<p>
	
	
		
		
		
		<br><html:submit value="Submit"/>
		</html:form>
	
	

	
	

</body>
</html:html>